Scene_Map.prototype.updateEncounterEffect = function() {
    if (this._encounterEffectDuration > 0) {
        this._encounterEffectDuration--;
        var speed = this.encounterEffectSpeed();
        var n = speed - this._encounterEffectDuration;  // 正数帧数
        var p = n / speed;                              // 动画进度
        var q = ((p - 1) * 20 * p + 5) * p + 1;         // 放大率（3次函数）
        var zoomX = $gamePlayer.screenX();
        var zoomY = $gamePlayer.screenY() - 24;
        this._backgroundBitmap
        // n=2时，截图作为战斗背景，开始闪烁（一半时间）。
        if (n === 2) {
            this.snapForBattleBackground();
            let encounterBitmap = SceneManager.snap();
            if (!this._encounterSprite) {
                this._encounterSprite = [];
                this._encounterSprite.push(new Sprite_Base());
                this._encounterSprite.push(new Sprite_Base());
                this._blackSprite = new Sprite_Base();
            }
            this.addChild(this._blackSprite);
            this.addChild(this._encounterSprite[0]);
            this.addChild(this._encounterSprite[1]);
            //var color = ;
            this._blackSprite.bitmap = new Bitmap(Graphics.boxWidth,Graphics.boxHeight);
            this._blackSprite.bitmap.fillRect(0,0,Graphics.boxWidth,Graphics.boxHeight,[255, 255, 255, 255]);
            this._encounterSprite[0].bitmap = encounterBitmap;
            this._encounterSprite[1].bitmap = encounterBitmap;
            this._encounterSprite[0].setFrame(0,0,Graphics.boxWidth/2,Graphics.boxHeight);
            this._encounterSprite[1].x = Graphics.boxWidth/2
            this._encounterSprite[1].setFrame(Graphics.boxWidth/2,0,Graphics.boxWidth/2,Graphics.boxHeight);

        }

        // 持续播放动画
        if (!!this._encounterSprite){
            this._encounterSprite[0].x = - p*(p+1) * Graphics.boxWidth;
            this._encounterSprite[1].x =  Graphics.boxWidth/2 + p*(p+1) * Graphics.boxWidth;
        }
        // n达到1/2总帧数时，播放战斗音乐，淡出战斗场景。
        if (n === Math.floor(speed / 2)) {
            this.startFadeOut(this.fadeSpeed());
        }
        if (n === speed) {
            this.removeChild(this._encounterSprite[0]);
            this.removeChild(this._encounterSprite[1]);
            this.removeChild(this._blackSprite);
            BattleManager.playBattleBgm();
        }
    }
};
/*
Scene_Map.prototype.updateEncounterEffect = function() {
    if (this._encounterEffectDuration > 0) {
        this._encounterEffectDuration--;
        var speed = this.encounterEffectSpeed();
        var n = speed - this._encounterEffectDuration;  // 正数帧数
        var p = n / speed;                              // 动画进度
        var q = ((p - 1) * 20 * p + 5) * p + 1;         // 放大率（3次函数）
        var zoomX = $gamePlayer.screenX();
        var zoomY = $gamePlayer.screenY() - 24;
        // n=2时，截图作为战斗背景，开始闪烁（一半时间）。
        if (n === 2) {
            $gameScreen.setZoom(zoomX, zoomY, 1);
            this.snapForBattleBackground();
            this.startFlashForEncounter(speed / 2);
        }
        // 持续缩放动画
        $gameScreen.setZoom(zoomX, zoomY, q);
        // n=达到1/6的总帧数时（10帧），再次闪烁（一半时间）
        if (n === Math.floor(speed / 6)) {
            this.startFlashForEncounter(speed / 2);
        }
        // n达到1/2总帧数时，播放战斗音乐，淡出战斗场景。
        if (n === Math.floor(speed / 2)) {
            BattleManager.playBattleBgm();
            this.startFadeOut(this.fadeSpeed());
        }
    }
};

Scene_Map.prototype.snapForBattleBackground = function() {
    this._windowLayer.visible = false;
    SceneManager.snapForBackground();
    this._windowLayer.visible = true;
};

Scene_Map.prototype.startFlashForEncounter = function(duration) {
    var color = [255, 255, 255, 255];
    $gameScreen.startFlash(color, duration);
};

Scene_Map.prototype.encounterEffectSpeed = function() {
    return 60;
};
*/